document.getElementById("file").onchange=function(){
	parseData()
}
function parseData(){
	var file=$("#file").prop("files")[0]
	var data=new FormData()
	data.append("file",file)
	$.ajax({
	"url":"/parse_data/",
	"error":errorAjax,
	"data":data,
	"type":"POST",
	"complete":stop_load_pic,
		"processData":false,
                "cache": false,
               "contentType": false,
	"beforeSend":start_load_pic,
	"success":function(data){
		document.getElementById("file").value="";
		data=JSON.parse(data)
		if(!data.status){
			showErrorInfo(data.content)
			window.batchUser=null
			return false;
		}
		var data=data.content
		window.batchUser=data
			var tab=document.getElementById("tab")	
			for(var i=0;i<data.length;i++){
				var tr=document.createElement("tr")

				var td=document.createElement("td")
				td.textContent=data[i][0];
				tr.appendChild(td)
			
				var td=document.createElement("td")
				td.textContent=data[i][1];
				tr.appendChild(td)
			
				var td=document.createElement("td")
				td.textContent=data[i][2];
				tr.appendChild(td)

				var td=document.createElement("td")
				td.textContent=data[i][3];
				tr.appendChild(td)
				tab.appendChild(tr)
			}
		showSuccessNotice("请不要忘记点击【确认创建】")
		
	}
	})
}
document.getElementById("create").onclick=function(){
	if(window.batchUser===null || window.batchUser===undefined){
		showErrorInfo("请上传有效的模板文件后再操作！")
		return false;
	}
	$.ajax({
		"url":"/batch_create_user/",
		"error":errorAjax,
		"type":"POST",
		"beforeSend":start_load_pic,
		"complete":stop_load_pic,
		"data":{"data":JSON.stringify(window.batchUser)},
		"success":function(data){
			alert("操作成功!")
			location.reload() } }) }
